#include<cstdio>//uncle-lu
#include<algorithm>
template<class T>void read(T &x)
{
	x=0;int f=0;char ch=getchar();
	while(ch<'0'||ch>'9') { f|=(ch=='-'); ch=getchar(); }
	while(ch<='9'&&ch>='0') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
	x = f ? -x : x;
	return ;
}

int n, W, cnt;
int v[2000], w[2000];
int F[40010];

int main()
{
	read(n);read(W);
	int x, y, m;
	for (int i = 1; i <= n; i++) 
	{
		read(x);read(y);read(m);
		int temp = 1;
		while(temp < m)
		{
			v[++cnt] = temp*x;
			w[cnt] = temp*y;
			m-=temp;
			temp <<= 1;
		}
		if(m != 0)
		{
			v[++cnt] = m*x;
			w[cnt] = m*y;
		}
	}

	for(int i=1; i<=cnt; ++i)
		for(int j=W; j>=w[i]; --j)
			F[j] = std::max(F[j], F[j-w[i]] + v[i]);

	printf("%d", F[W]);

	return 0;
}
